package com.ygqh.baby.model.wdt;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonProperty;

public class WdtMethodParam {
	@JsonProperty("Content")
	private String Content;
	@JsonProperty("Sign")
	private String Sign;
	@JsonProperty("InterfaceID")
	private String InterfaceID;
	@JsonProperty("SellerID")
	private String SellerID;
	@JsonProperty("Method")
	private String Method;

	public Map<String, Object> toMap() {
		Map<String, Object> map = new HashMap<String, Object>();
		Field[] fields = this.getClass().getDeclaredFields();
		for (Field field : fields) {
			Object obj;
			try {
				obj = field.get(this);
				if (obj != null) {
					map.put(field.getName(), obj);
				}
			} catch (IllegalArgumentException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			}
		}
		return map;
	}

	public String methodParam(Map<String, Object> map) {
		ArrayList<String> list = new ArrayList<String>();
		for (Map.Entry<String, Object> entry : map.entrySet()) {
			if (entry.getValue() != "") {
				list.add(entry.getKey() + "=" + entry.getValue() + "&");
			}
		}
		int size = list.size();
		String[] arrayToSort = list.toArray(new String[size]);
		StringBuilder sb = new StringBuilder();
		for (int i = 0; i < size; i++) {
			sb.append(arrayToSort[i]);
		}
		String result = sb.toString();
		return result.substring(0, result.length() - 1);

	}
	@JsonProperty("Content") 
	public String getContent() {
		return Content;
	}

	public void setContent(String content) {
		Content = content;
	}
	@JsonProperty("Sign") 
	public String getSign() {
		return Sign;
	}

	public void setSign(String sign) {
		Sign = sign;
	}
	@JsonProperty("InterfaceID") 
	public String getInterfaceID() {
		return InterfaceID;
	}

	public void setInterfaceID(String interfaceID) {
		InterfaceID = interfaceID;
	}
	@JsonProperty("SellerID") 
	public String getSellerID() {
		return SellerID;
	}

	public void setSellerID(String sellerID) {
		SellerID = sellerID;
	}
	@JsonProperty("Method") 
	public String getMethod() {
		return Method;
	}
	
	public void setMethod(String method) {
		Method = method;
	}

}
